package com.study.shengsiyuan.example10;

import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;
import java.net.UnknownHostException;

public class OldIOClient {
	public static void main(String[] args) throws UnknownHostException, IOException {

		Socket socket = new Socket("127.0.0.1",8899);
		String fileName = "F:\\百度网盘\\24248\\1-31\\28_gRPC与Gradle流畅整合及问题解决的完整过程与思考.mkv";
		InputStream  inputStream =new FileInputStream(fileName);
		DataOutputStream dataOutputStream =new DataOutputStream(socket.getOutputStream());
		byte[] buffer =new byte[4096];
		long readCount ;
		long total =0;
		long startTime =System.currentTimeMillis();
		while((readCount = inputStream.read(buffer))!=-1) {
			total+= readCount;
			dataOutputStream.write(buffer);
		}
		System.out.println("发送总字节数 ： "+ total +" , 耗时 ： "+(System.currentTimeMillis()-startTime));

		dataOutputStream.close();
		inputStream.close();
		socket.close();
	}
}
